#include<windows.h>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include"resource.h"
#include<shlobj.h>

HWND hwnd;
char *textfis=NULL;

void citirefisier()
{OPENFILENAME ofn;
 char szFileName[MAX_PATH]="";

 ZeroMemory(&ofn, sizeof(ofn));

 ofn.lStructSize=sizeof(ofn);
 ofn.hwndOwner=hwnd;
 ofn.lpstrFilter="Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0";
 ofn.lpstrFile=szFileName;
 ofn.nMaxFile=MAX_PATH;
 ofn.Flags=OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
 ofn.lpstrDefExt="txt";

 if(GetOpenFileName(&ofn))
	{FILE *f=fopen(szFileName,"rt");
	 char a[1024];

	 if(f==NULL)
		{MessageBox(hwnd,"Fisierul trebuie sa fie de tipul 'txt'!","", MB_OK | MB_ICONINFORMATION);
		 return;
		}
	 while(!feof(f))
		{fgets(a,1024,f);
		 if(textfis==NULL)
			{textfis=(char*)realloc(textfis,strlen(a)+1);
			 strcpy(textfis,a);
			}
		 else
			{textfis=(char*)realloc(textfis,strlen(textfis)+strlen(a)+1);
			 strcat(textfis,a);
			}
		}
	 fclose(f);
	}
}